/**
 * 
 */
package bus;

import org.springframework.validation.Errors;
import org.springframework.validation.Validator;

/**
 * @spring.bean id="albumManagementValidator"
 * @author isaac
 *
 */
public class AlbumManagementValidator implements Validator {

	/* (non-Javadoc)
	 * @see org.springframework.validation.Validator#supports(java.lang.Class)
	 */
	public boolean supports(Class clazz) {
		return clazz.equals(AlbumManagement.class);
	}

	/* (non-Javadoc)
	 * @see org.springframework.validation.Validator#validate(java.lang.Object, org.springframework.validation.Errors)
	 */
	public void validate(Object form, Errors errors) {
		AlbumManagement albumManagementForm = (AlbumManagement)form;
		
		/**
		 * @todo - Make sure that this is actually a valid path.
		 */
		if("".equals(albumManagementForm.getPath())) {
			errors.rejectValue("path", "error.not-specified", null, "Path is required.");
		}

	}
}